<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{% block title %}图书馆管理系统{% endblock %}</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <!-- 自定义样式 -->
    {% load static %}
    <link href="{% static 'css/styles.css' %}" rel="stylesheet">
    <style>
        :root {
            --primary-color: #66cdaa;
            --secondary-color: #34495e;
            --accent-color: #98fb98;
            --primary-gradient: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
        }

        body {
            background-color: #f0fff0;
            font-family: "Microsoft YaHei", sans-serif;
        }

        /* 增强导航栏选择器特异性 */
        nav.navbar {
            background: var(--primary-gradient) !important;
            box-shadow: 0 2px 4px rgba(0,0,0,.1);
        }

        .navbar-brand {
            color: white !important;
            font-weight: bold;
        }

        .navbar .nav-link {
            color: rgba(255,255,255,.8) !important;
            transition: color 0.3s ease;
        }

        .navbar .nav-link:hover {
            color: white !important;
            background-color: rgba(255,255,255,0.1);
        }

        /* 调整移动端菜单按钮颜色 */
        .navbar-toggler-icon {
            filter: invert(1);
        }
    </style>
</head>
<body>
    <!-- 移除navbar-dark类 -->
    <nav class="navbar navbar-expand-lg mb-4">
        <div class="container">
            <a class="navbar-brand" href="{% url 'index' %}">
                <i class="fas fa-book-reader me-2"></i>图书馆管理系统
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link {% if request.path == '/catalog/' %}active{% endif %}" href="{% url 'index' %}">
                            <i class="fas fa-home me-1"></i>首页
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {% if '/books/' in request.path %}active{% endif %}" href="{% url 'books' %}">
                            <i class="fas fa-book me-1"></i>所有图书
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {% if '/authors/' in request.path %}active{% endif %}" href="{% url 'authors' %}">
                            <i class="fas fa-user-edit me-1"></i>作者列表
                        </a>
                    </li>
                </ul>
                <ul class="navbar-nav">
                    {% if user.is_authenticated %}
                    <li class="nav-item">
                        <a class="nav-link {% if '/mybooks/' in request.path %}active{% endif %}" href="{% url 'my-borrowed' %}">
                            <i class="fas fa-bookmark me-1"></i>我的借阅
                        </a>
                    </li>
                    <li class="nav-item">
                        <form action="{% url 'logout' %}" method="post" style="display:inline;">
                            {% csrf_token %}
                            <button type="submit" class="nav-link btn btn-link" style="display:inline; padding:0; border:none; background:none;">
                                <i class="fas fa-sign-out-alt me-1"></i>退出
                            </button>
                        </form>
                    </li>
                    {% else %}
                    <li class="nav-item">
                        <a class="nav-link {% if '/accounts/login/' in request.path %}active{% endif %}" href="{% url 'login' %}">
                            <i class="fas fa-sign-in-alt me-1"></i>登录
                        </a>
                    </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>

    <div class="container animate-fade-in">
        <div class="row">
            <div class="col-md-9">
                {% if messages %}
                {% for message in messages %}
                <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                    <i class="fas fa-info-circle me-2"></i>{{ message }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                </div>
                {% endfor %}
                {% endif %}

                {% block content %}{% endblock %}
            </div>
            <div class="col-md-3">
                <div class="sidebar">
                    {% block sidebar %}
                    <h4><i class="fas fa-info-circle me-2"></i>馆藏信息</h4>
                    <hr>
                    <ul class="list-unstyled">
                        <li><i class="fas fa-book me-2"></i>图书总数：{{ num_books }}</li>
                        <li><i class="fas fa-copy me-2"></i>副本数量：{{ num_instances }}</li>
                        <li><i class="fas fa-check me-2"></i>可借数量：{{ num_instances_available }}</li>
                        <li><i class="fas fa-users me-2"></i>作者数量：{{ num_authors }}</li>
                    </ul>
                    {% endblock %}
                </div>
            </div>
        </div>
    </div>

    <footer class="mt-5 py-3 bg-light">
        <div class="container text-center">
            <p class="mb-0 text-muted">系统所有者f22016406李柳婵</p>
        </div>
    </footer>

    <!-- Bootstrap Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>